<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="model.*"%>
<%
	ProjectModel obj;
	Object temp = request.getAttribute("document");
	if (temp != null) {
		try {
			obj = (ProjectModel) temp;
		} catch (Exception ex) {
			obj = new ProjectModel();
		}
	} else {
		obj = new ProjectModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Project </title>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<link rel="stylesheet" href="css/datepicker.css" />
<link rel="stylesheet" href="css/common.css" />
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.6.1.min.js"></script>

<script language="javascript" type="text/javascript">
	var requiredInputs = [['name','name_required'],['code','code_required'],['description','description_required'],['id_type','id_type_required'],['pm','pm_required'],['status','status_required'],['plan_start_date','plan_start_date_date_required', 'plan_start_date','plan_start_date_time_required'],['plan_end_date','plan_end_date_date_required', 'plan_end_date','plan_end_date_time_required'],['real_start_date','real_start_date_date_required', 'real_start_date','real_start_date_time_required'],['real_end_date','real_end_date_date_required', 'real_end_date','real_end_date_time_required'],['id_company','id_company_required']];
	var intInputs = [['id_type','id_type_invalid'],['pm','pm_invalid'],['status','status_invalid'],['id_company','id_company_invalid']];
	var doubleInputs = [];
	var dateInputs = [['plan_start_date','plan_start_date_date_invalid'],['plan_end_date','plan_end_date_date_invalid'],['real_start_date','real_start_date_date_invalid'],['real_end_date','real_end_date_date_invalid']];
	var timeInputs = [['plan_start_date','plan_start_date_time_invalid'],['plan_end_date','plan_end_date_time_invalid'],['real_start_date','real_start_date_time_invalid'],['real_end_date','real_end_date_time_invalid']];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
	<form action="projectServlet?mode=insert" method="post"
        onSubmit="return checkInputs()"
        onreset="return confirm('Do you really want to reset the form?')">
		<table class="tblInput" border="1">
			<tr class="inputHeader">
				<td colspan="3" class="inputHeader">Create New Project </td>
			</tr>
			<tr class="trField">
				<td class="tdFieldName">Name </td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="name" name="name" maxlength="255" value="<%=obj.getName()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="name_required" class="errMsg" style="display: none;">Name  is required</span>
					<span id="name_invalid" class="errMsg" style="display: none;">Name  is invalid</span>
                    <span id="name_error" class="errMsg"><%=obj.errMsgs.Name%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Code </td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="code" name="code" maxlength="20" value="<%=obj.getCode()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="code_required" class="errMsg" style="display: none;">Code  is required</span>
					<span id="code_invalid" class="errMsg" style="display: none;">Code  is invalid</span>
                    <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Description </td>				    <td class="tdFieldInput">
					<textarea id="description" name="description" rows="5" class="inputTextarea"><%=obj.getDescription()%></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="description_required" class="errMsg" style="display: none;">Description  is required</span>
					<span id="description_invalid" class="errMsg" style="display: none;">Description  is invalid</span>
                    <span id="description_error" class="errMsg"><%=obj.errMsgs.Description%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Type </td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_type" name="id_type" maxlength="10" value="<%=obj.getIdType()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_type_required" class="errMsg" style="display: none;">Id Type  is required</span> 
					<span id="id_type_invalid" class="errMsg" style="display: none;">Id Type  is invalid</span>
                    <span id="id_type_error" class="errMsg"><%=obj.errMsgs.IdType%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Pm </td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="pm" name="pm" maxlength="10" value="<%=obj.getPm()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="pm_required" class="errMsg" style="display: none;">Pm  is required</span> 
					<span id="pm_invalid" class="errMsg" style="display: none;">Pm  is invalid</span>
                    <span id="pm_error" class="errMsg"><%=obj.errMsgs.Pm%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Is Template </td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_is_template" name="ckb_is_template"
								onchange="toggleControls(['is_template_true', 'is_template_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="is_template_true" name="is_template" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="is_template_false" name="is_template" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">Status </td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="status" name="status" maxlength="10" value="<%=obj.getStatus()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="status_required" class="errMsg" style="display: none;">Status  is required</span> 
					<span id="status_invalid" class="errMsg" style="display: none;">Status  is invalid</span>
                    <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Plan Start Date </td>				<td class="tdFieldInput">
					<table class="tblDateTime">
						<tr class="trDateTime">
							<td class="tdDate">
								<input type="text" maxlength="10" class="inputDate" id="plan_start_date_date" name="plan_start_date_date" value="<%=obj.getPlanStartDate()%>" /> 
								<input type="button" class="btnCalendar" value="..."
									onclick="javascript:displayDatePicker('plan_start_date_date', this, dateFormat);" />
							</td>
							<td class="tdTime">
								<input type="text" maxlength="5" class="inputTime" id="plan_start_date_time" name="plan_start_date_time" value="<%=obj.getPlanStartDate()%>" />
							</td>
						</tr>
					</table></td>
				<td class="tdErrMsg">
                    <span id="plan_start_date_error" class="errMsg"><%=obj.errMsgs.PlanStartDate%></span>
					<div class="divErr">
						<span id="plan_start_date_date_required" class="errMsg"
							style="display: none;">Plan Start Date 's date is required</span>
					</div>
					<div class="divErr">
						<span id="plan_start_date_time_required" class="errMsg"
							style="display: none;">Plan Start Date 's time is required</span>
					</div>
					<div class="divErr">
						<span id="plan_start_date_date_invalid" class="errMsg"
							style="display: none;">Plan Start Date 's date is invalid</span>
					</div>
					<div class="divErr">
						<span id="plan_start_date_time_invalid" class="errMsg"
							style="display: none;">Plan Start Date 's time is invalid</span>
					</div>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Plan End Date </td>				<td class="tdFieldInput">
					<table class="tblDateTime">
						<tr class="trDateTime">
							<td class="tdDate">
								<input type="text" maxlength="10" class="inputDate" id="plan_end_date_date" name="plan_end_date_date" value="<%=obj.getPlanEndDate()%>" /> 
								<input type="button" class="btnCalendar" value="..."
									onclick="javascript:displayDatePicker('plan_end_date_date', this, dateFormat);" />
							</td>
							<td class="tdTime">
								<input type="text" maxlength="5" class="inputTime" id="plan_end_date_time" name="plan_end_date_time" value="<%=obj.getPlanEndDate()%>" />
							</td>
						</tr>
					</table></td>
				<td class="tdErrMsg">
                    <span id="plan_end_date_error" class="errMsg"><%=obj.errMsgs.PlanEndDate%></span>
					<div class="divErr">
						<span id="plan_end_date_date_required" class="errMsg"
							style="display: none;">Plan End Date 's date is required</span>
					</div>
					<div class="divErr">
						<span id="plan_end_date_time_required" class="errMsg"
							style="display: none;">Plan End Date 's time is required</span>
					</div>
					<div class="divErr">
						<span id="plan_end_date_date_invalid" class="errMsg"
							style="display: none;">Plan End Date 's date is invalid</span>
					</div>
					<div class="divErr">
						<span id="plan_end_date_time_invalid" class="errMsg"
							style="display: none;">Plan End Date 's time is invalid</span>
					</div>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Real Start Date </td>				<td class="tdFieldInput">
					<table class="tblDateTime">
						<tr class="trDateTime">
							<td class="tdDate">
								<input type="text" maxlength="10" class="inputDate" id="real_start_date_date" name="real_start_date_date" value="<%=obj.getRealStartDate()%>" /> 
								<input type="button" class="btnCalendar" value="..."
									onclick="javascript:displayDatePicker('real_start_date_date', this, dateFormat);" />
							</td>
							<td class="tdTime">
								<input type="text" maxlength="5" class="inputTime" id="real_start_date_time" name="real_start_date_time" value="<%=obj.getRealStartDate()%>" />
							</td>
						</tr>
					</table></td>
				<td class="tdErrMsg">
                    <span id="real_start_date_error" class="errMsg"><%=obj.errMsgs.RealStartDate%></span>
					<div class="divErr">
						<span id="real_start_date_date_required" class="errMsg"
							style="display: none;">Real Start Date 's date is required</span>
					</div>
					<div class="divErr">
						<span id="real_start_date_time_required" class="errMsg"
							style="display: none;">Real Start Date 's time is required</span>
					</div>
					<div class="divErr">
						<span id="real_start_date_date_invalid" class="errMsg"
							style="display: none;">Real Start Date 's date is invalid</span>
					</div>
					<div class="divErr">
						<span id="real_start_date_time_invalid" class="errMsg"
							style="display: none;">Real Start Date 's time is invalid</span>
					</div>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Real End Date </td>				<td class="tdFieldInput">
					<table class="tblDateTime">
						<tr class="trDateTime">
							<td class="tdDate">
								<input type="text" maxlength="10" class="inputDate" id="real_end_date_date" name="real_end_date_date" value="<%=obj.getRealEndDate()%>" /> 
								<input type="button" class="btnCalendar" value="..."
									onclick="javascript:displayDatePicker('real_end_date_date', this, dateFormat);" />
							</td>
							<td class="tdTime">
								<input type="text" maxlength="5" class="inputTime" id="real_end_date_time" name="real_end_date_time" value="<%=obj.getRealEndDate()%>" />
							</td>
						</tr>
					</table></td>
				<td class="tdErrMsg">
                    <span id="real_end_date_error" class="errMsg"><%=obj.errMsgs.RealEndDate%></span>
					<div class="divErr">
						<span id="real_end_date_date_required" class="errMsg"
							style="display: none;">Real End Date 's date is required</span>
					</div>
					<div class="divErr">
						<span id="real_end_date_time_required" class="errMsg"
							style="display: none;">Real End Date 's time is required</span>
					</div>
					<div class="divErr">
						<span id="real_end_date_date_invalid" class="errMsg"
							style="display: none;">Real End Date 's date is invalid</span>
					</div>
					<div class="divErr">
						<span id="real_end_date_time_invalid" class="errMsg"
							style="display: none;">Real End Date 's time is invalid</span>
					</div>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Company </td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_company" name="id_company" maxlength="10" value="<%=obj.getIdCompany()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_company_required" class="errMsg" style="display: none;">Id Company  is required</span> 
					<span id="id_company_invalid" class="errMsg" style="display: none;">Id Company  is invalid</span>
                    <span id="id_company_error" class="errMsg"><%=obj.errMsgs.IdCompany%></span>
                </td></tr>
			
			<tr class="trInputBottom">
				<td class="trInputBottom" colspan="3">
					<table class="tblSubmit" align="center">
						<tr class="trSubmit">
							<td class="tdSubmit"><input type="submit" value="Submit" />
							</td>
							<td class="tdReset"><input type="reset" value="Reset" /></td>
						</tr>
					</table></td>
			</tr>
		</table>
	</form>
</body>
</html>